#导入
from sqlalchemy import Column,Integer,String,create_engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base

#创建基类
Base=declarative_base()

#定义Phonebook对象
class Phonebook(Base):
	#表的名字
	__tablename__='phonebook'

	#表的结构
	id=Column(Integer,primary_key=True)
	name=Column(String(64),nullable=False)
	sex=Column(String(1))
	phone=Column(String(64))
	email=Column(String(64))

#初始化数据库连接
engine=create_engine('mysql+pymysql://root:root@127.0.0.1:3306/family?charset=utf8')

#创建DBSession类型
DBSession=sessionmaker(bind=engine)